home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / cfhttp.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  2.2 KB  |  72 lines

  1. <!--- This example shows the use of CFHTTP to pull information
  2. dynamically from the snippets directory --->
  3. <HTML>
  4. <HEAD>
  5. <TITLE>
  6. CFHTTP Example
  7. </TITLE>
  8. </HEAD>
  9.  
  10. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  11. <BODY  bgcolor="#FFFFD5">
  12.  
  13. <H3>CFHTTP Example</H3>
  14. <P>This example shows the ability of CFHTTP to pull
  15. the contents of a web resource from the Internet 
  16. or from a local directory.
  17.  
  18. <P>This example has been disabled for online viewing.  Please use your copy of ColdFusion to view this example.
  19. <!---
  20. <FORM ACTION="cfhttp.cfm" METHOD="POST">
  21. Try entering a URL for the tag to return:
  22. <INPUT TYPE="Text" size=25 NAME="urladdress" VALUE="http://www.allaire.com">
  23. <INPUT TYPE="Submit" NAME="" VALUE="get page">
  24. </FORM>
  25.  
  26. <!--- sets a default value for a URL to retrieve --->
  27. <!--- If this example fails to run correctly, you may need to 
  28.       change localhost to the name
  29.       of the CF Server that contains CFDOCS --->
  30. <CFPARAM name="urladdress" default="http://localhost/cfdocs/index.htm">
  31.  
  32. <!--- if we have passed a url address in the form, we
  33. want to display the passed address --->
  34. <CFIF IsDefined("form.urladdress") is True>
  35. <!--- do simple error check to avoid crashing the
  36. tag --->
  37.     <CFIF Trim(Form.urladdress) is "" or Trim(Form.urladdress) is "http://">
  38. <!--- if error condition tripped, set alternative --->
  39.         <CFSET urlAddress ="http://localhost/cfdocs/index.htm">
  40.         <H4>because you entered no url or an empty string, the tag
  41.         will return the following address: http://localhost/cfdocs/index.htm</H4>
  42.  
  43.     <CFELSE>
  44. <!--- otherwise use address passed from form --->
  45.         <CFSET urlAddress = form.urladdress>
  46.     </CFIF>
  47. <!--- now use the CFHTTP tag to get the file content
  48. represented by urladdress --->    
  49.         <CFHTTP URL="#urladdress#"
  50.             METHOD="GET"
  51.             RESOLVEURL=YES>
  52.         </CFHTTP>
  53. <CFELSE>
  54. <!--- the first time through, retrieve a URL that we know
  55. exists --->
  56. <CFHTTP URL="http://localhost/cfdocs/index.htm"
  57.     METHOD="GET"
  58.     RESOLVEURL=YES>
  59. </CFHTTP>
  60. </CFIF>
  61.  
  62. <!--- Now, output the file, including the mimetype and content --->
  63. <H3>Show the file</H3>
  64.  
  65. <CFOUTPUT>
  66. <P>Your file was of type: #CFHTTP.MimeType#
  67. <P>#HTMLCodeFormat(CFHTTP.FileContent)#
  68. </CFOUTPUT>
  69.  --->
  70. </BODY>
  71. </HTML>       
  72.